package com.simple.shiro;

import org.apache.shiro.session.Session;
import org.apache.shiro.session.SessionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.simple.utils.SysConfig;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * session 监听
 */
public class ShiroSessionListener implements SessionListener {

    private static final Logger logger = LoggerFactory.getLogger(ShiroSessionListener.class);

    private final AtomicInteger sessionCount=new AtomicInteger(0);

    @Override
    public void onStart(Session session) {

    }

    @Override
    public void onStop(Session session) {
        logger.info("-->会话退出方法执行 ，退出者:"+session.getAttribute(SysConfig.USER_SESSION_KEY));
        sessionCount.decrementAndGet();
    }

    @Override
    public void onExpiration(Session session) {

    }
}
